<?php

class Skjb_View_Helper_ShortenText extends Zend_View_Helper_Abstract
{
    function shortenText($inString, $charLimit){
    	if (mb_strlen($inString) < $charLimit){
    	    return strip_tags($inString);
    	}
        
	    $inString = strip_tags($inString);
	    $inString = mb_substr($inString, 0, $charLimit); // Ensure no longer than required characters
	    $lastSpace = mb_strrpos($inString, ' ');
	    if ($lastSpace) {
	        $inString = mb_substr($inString, 0, $lastSpace);
        }
        
	    return $inString;
    }
}
